This repository contains all the data and code needed to replicate the analysis reported in Ahlquist & Ansell "Taking Credit." World Politics.

Using this code to re-estimate the models in the paper requires access to R (v.>= 3.0.0) and WinBUGS/GeoBUGS.  Code calling models without CAR priors should also run in JAGS but this has not been verified.

The repository contains two main directories:
1) Data: 
AhlquistAnsellWorldPoliticsReplicationData.csv: The main data file containing all the necessary data merged from a variety of sources described in the main text.  This dataset is far bigger than what is analyzed in the paper due to the source data.  The code for selecting country-years and variables for specific models in included in the Code directory.

SpatialWeights.RData: Spatial connectivity matricies for the CAR prior models described in the paper and the appendix.

2) Code: all R and WinBUGS/GeoBUGS code needed to estimate the models and produce the tables and graphics reported in the main article as well as the online appendix document.

In the main Code directory:

- AhlquistAnsellMainModelFitting.R: The file that loads and selects data, generates plots, calls BUGS models, and produces post-fitting analysis and interpretation for all the models reported in the main text of the paper.
- AhlquistAnsellMainModel.bug: BUGS code for the core model reported in the main text of the paper.
- AhlquistAnsellCARmodel.bug: BUGS code for the CAR prior models 
- AhlquistAnsellDisproportionalityModel.bug: BUGS code for model using disproportionality in place of cumulative left government 
- AhlquistAnsellENPPmodel.bug: BUGS code for model using ENPP in place of cumulative left government
- AhlquistAnsellMajoritarianModel.bug: BUGS code for model using majoritarian dummy variable in place of cumulative left government
- AhlquistAnsellNoInteractionModel.bug: BUGS code for model without inequality x cumulative left government
- AhlquistAnsellNoVariance.bug:  BUGS code for model without hiearchical variance structure

In the Appendix models subdirectory:  Code neccessary for reproducing the estimates and figures in the supplementary appendix.

- AhlquistAnsellCumGov.R: loads and selects data, generates plots, calls BUGS models with different measures of long-term partisanship.
- AppendixCenterLeft.bug: BUGS code for model using cumulative center-Left partisanship
- AppendixCumGov.bug: BUGS code for model using cumulative center-Left partisanship
- AhlquistAnsellLeaveCountryOut.R: loads and selects data, generates plots, calls BUGS models that iteratively leave out specific countries. This requires AhlquistAnsellMainModel.bug from the Code directory.
- AhlquistAnsellNoImpute.R: loads and selects data, generates plots, calls the two following BUGS models with that are fit only to complete cases (i.e., no imputation of missing data in the MCMC). 
- AppendixNoImputeFull.bug: BUGS code for main model that analyzes complete cases only.
- AppendixNoImputeSimple.bug: BUGS code for simple model extending back to 1960s  
- AppendixFIRE.R: Fits model that includes employment in FIRE sector
- AppendixFIRE.bug: BUGS code for FIRE model
- AppendixSavingsModels.R: R code for models for household savings as DV
- AppendixSavings.bug: BUGS code for savings model using majoritarian dummy
- AppendixSavingsFull.bug: BUGS code for savings model using cummulative left govt

AppendixSavingsModels.R
